#!/usr/bin/env python 
# -*- coding:utf-8 -*-

import os
from datetime import datetime

import asyncio
from apscheduler.schedulers.blocking import BlockingScheduler


def tick():
    print('Tick! The time is: %s' % datetime.now())


async def tick2():
    print('Tick start! The time is: %s' % datetime.now())

    # async for document in taoke_accounts_coll.find({}, limit=10000):  # 查询所有文档
    #     print('23 = {}'.format(document))
    await asyncio.sleep(3)

    print('Tick end! The time is: %s' % datetime.now())
    return True


if __name__ == '__main__':
    scheduler = BlockingScheduler()
    # scheduler.add_job(tick, 'interval', seconds=3)
    scheduler.add_job(tick2, 'interval', seconds=3)
    print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))

    try:
        scheduler.start()
    except (KeyboardInterrupt, SystemExit):
        pass
